package cn.tedu.spring.life;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Scope(value = "singleton")
@Component
public class Life {
    private String meaning;

    public Life() {
        System.out.println("Life()，1.实例化，bean对象创建——构造方法");
    }

    @Value("生活是美好的")
    public void setMeaning(String meaning) {
        System.out.println("setMeaning()，2.属性赋值——set方法");
        this.meaning = meaning;
    }

    @PostConstruct
    public void init() {
        System.out.println("init()，3.生命周期初始化（人为干预）——普通方法");
    }

    @PreDestroy
    public void destroy() {
        System.out.println("destroy()，5.生命周期销毁（人为干预）——普通方法");
    }
}
